package com.example;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created with IntelliJ IDEA.
 * User: Jasic_Work
 * Date: 12-9-12
 * Time: 上午10:18
 * <p/>
 * DatabaseHelper
 * 1、getReadableDatabase()、getWritableDatabase()可获得一个SQLiteDatabase对象
 */
public class MySQLiteManager extends SQLiteOpenHelper {

    private static int VERSION = 1;


    public MySQLiteManager(Context context, String name, int version) {
        this(context, name, null, version);
    }

    public MySQLiteManager(Context context, String name) {
        this(context, name, null, VERSION);
    }

    public MySQLiteManager(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        System.out.println("Creating DateBase...");
        System.out.println("Creating table A...");
        db.execSQL("create table test(id int primary key,name varchar(20));");
        System.out.println("Created table A...");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        System.out.println("MySQLiteManager's onUpgrade method has been executed...");
    }
}
